{{ extend '../pub/template.html'}}

{{ block 'user-name' }}
当前登录用户{{msg}}&nbsp;&nbsp;用户角色：{{role == 'on' ? '管理员':'普通人'}}
{{ /block }}

{{ block 'user-position'}}
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="/admin/user">首页</a></li>
    <li class="breadcrumb-item"><a>友情链接管理</a></li>
    <li class="breadcrumb-item active" aria-current="page">添加链接</li>
  </ol>
</nav>

<div class="card border-0" style="margin: 16px;padding: 16px;min-height: 400px;">
  <form method="POST" action="/admin/linksadd" id="userForm">

    <!-- 链接地址 -->
    <div class="form-group ">
      <label for="staticEmail" class="col-sm-2 col-form-label col-form-label-sm">链接地址：</label>
      <div class="col-sm-10">
        <input type="text" class="form-control form-control-sm" name="url" id="url"
          placeholder="例如：https://www.baidu.com">
      </div>
    </div>

    <!-- 链接名称 -->
    <div class="form-group ">
      <label for="inputAuthor" class="col-sm-2 col-form-label col-form-label-sm">链接名称</label>
      <div class="col-sm-10">
        <input type="text" class="form-control form-control-sm" name="name" id="name" placeholder="例如：百度">
      </div>
    </div>

    <!-- alt -->
    <div class="form-group">
      <label for="editor" class="col-sm-2 col-form-label col-form-label-sm">提示文字</label>
      <div class="col-sm-10">
        <input type="text" class="form-control form-control-sm" name="alt" id="alt">
      </div>
    </div>

    <!-- 提交按钮 -->
    <div class="form-group">
      <div class="col-sm-10"><button type="submit" class="btn btn-primary">提交</button></div>
    </div>

  </form>
</div>

{{ /block}}

{{block 'script'}}
<script>
  $('#userForm').on('submit', function () {
    if ($('#url').val().trim().length == 0) {
      alert('内容不能为空')
      return false;
    } else if ($('#name').val().trim().length == 0) {
      alert('内容不能为空')
      return false;
    } else if ($('#alt').val().trim().length == 0) {
      alert('内容不能为空')
      return false;
    }
  })
</script>





{{/block}}